package com.example.controller;

import com.example.loader.HazelcastCacheLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class TestCachingController {

    Logger logger = LoggerFactory.getLogger(getClass());

    @Resource
    private HazelcastCacheLoader hazelcastCacheLoader;

    /***
     * 设置缓存信息
     */
    @RequestMapping("putCache")
    public void putCache() {
        this.hazelcastCacheLoader.getCache().put("xxxx", "xxxxxxx123456789");
        logger.warn("putCache putCache putCache putCache 。。。");
    }

    /***
     * 获取缓存信息
     * @return
     */
    @RequestMapping("getCache")
    public String getCache() {
        logger.warn("getCache getCache getCache getCache 。。。");
        return this.hazelcastCacheLoader.getCache().get("xxxx");
    }
}
